home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Oberon⁄F™ 1.1 / Obx / Docu / Hello1 (.txt) < prev    next >
Encoding:
Oberon Document  |  1996-01-05  |  4.1 KB  |  59 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. Helvetica
  17. Helvetica
  18. Helvetica
  19. TextRulers.StdRulerDesc
  20. TextRulers.RulerDesc
  21. TextRulers.StdStyleDesc
  22. TextRulers.StyleDesc
  23. TextRulers.AttributesDesc
  24. Helvetica
  25. MODULE ObxHello1;
  26.     IMPORT Views, TextModels, TextMappers, TextViews;
  27.     PROCEDURE Do*;
  28.         VAR t: TextModels.Model; f: TextMappers.Formatter; v: TextViews.View;
  29.     BEGIN
  30.         t := TextModels.dir.New();    (* create a new, empty text *)
  31.         f.ConnectTo(t);    (* connect a formatter to the text *)
  32.         f.WriteString("Hello World"); f.WriteLn;    (* write string and 0DX into new text *) 
  33.         v := TextViews.dir.New(t);    (* create a new text view for t *)
  34.         Views.OpenView(v)    (* open the view in a window *)
  35.     END Do;
  36. END ObxHello1.
  37. TextControllers.StdCtrlDesc
  38. TextControllers.ControllerDesc
  39. Containers.ControllerDesc
  40. Controllers.ControllerDesc
  41. Helvetica
  42. DevCommanders.StdViewDesc
  43. DevCommanders.ViewDesc
  44. Helvetica
  45. Oberon by Example: ObxHello1
  46. Everything in Oberon/F revolves around views. A view is a rectangular part of a document; documents consist of a hierarchy of nested views. This text is a text view; below is another text view embedded in it:
  47.  ObxHello1.Do
  48. The embedded text view above contains a slightly more advanced hello world program than ObxHello0. It doesn't use module Out to write into the log window; instead it creates a new empty text, to which it connects a text formatter. A text formatter is an object which provides procedures to write variables of all basic Oberon types into a text. In the above example, a string and a carriage return are written to the text, which means that they are appended to the existing text. Since a newly created text is empty, t now contains exactly what the formatter has written into it.
  49. A text is an object which carries text and text attributes; i.e. a sequence of characters and information about font, color, and vertical offset of each character. However, a text does not know how to draw itself; this is the purpose of a text view. (Yes, what you are currently looking at is the output of such a view.) When a text view is created, it receives the text to be displayed as a parameter. Several views on the same text can be open simultaneously. When you edit in one window, the changes are propagated to all other windows on the same text.
  50. When you create a text, you can follow the steps outlined below:
  51. 1) create a text model
  52. 2) connect a text formatter to it
  53. 3) write the text's context via the formatter
  54. 4) create a text view for the model
  55. 5) open the text view in a window
  56. In this example, we have seen how to use the text subsystem in order to create a new text.
  57. Helvetica
  58. Documents.ControllerDesc
  59.